CREATE PROCEDURE coreWFExitActionsDeleteByID
(
	@id	int
)
AS
	DECLARE @DeletedRank int;
	DECLARE @ExitPathID int;
	
	SELECT @DeletedRank=Rank, @ExitPathID=FK_ExitPathID FROM WFExitActions WHERE PK_ID=@id;
	
	IF NOT @DeletedRank IS NULL
	BEGIN
		DELETE FROM WFExitActions WHERE PK_ID=@id;
		UPDATE WFExitActions SET Rank=Rank-1 WHERE FK_ExitPathID=@ExitPathID AND Rank>@DeletedRank;
	END